package com.ssy.lingxi.after.sale.model.constant;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 换货发货状态
 * @author 伍将
 * @date 2020/9/17
 * @version 2.0.0
 */
public enum ReplaceDeliveryGoodsStatusEnum {
    /**
     * 所有
     */
    ALL(0, "所有", "", ""),
    /**
     * 未确认换货发货
     */
    TO_BE_CONFIRM_DELIVERY(1, "未确认换货发货", "未确认换货发货", "未确认换货发货"),
    /**
     * 已确认换货发货
     */
    CONFIRM_DELIVERY(2, "已确认换货发货", "待确认换货收货", "已确认换货发货"),
    /**
     * 已确认换货收货(未确认回单)
     */
    CONFIRM_RECEIVE(3, "已确认换货收货", "已确认换货收货", "待确认换货回单"),
    /**
     * 确认回单
     */
    CONFIRM_RECEIPT(4, "确认回单", "已确认换货回单", "已确认换货回单");

    private final Integer code;
    private final String message;
    private final String consumerName;
    private final String supplierName;

    ReplaceDeliveryGoodsStatusEnum(Integer code, String message, String consumerName, String supplierName) {
        this.code = code;
        this.message = message;
        this.consumerName = consumerName;
        this.supplierName = supplierName;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getDeclaringClass(), this.getCode());
    }

    public String getConsumerName() {
        return LanguageHolder.getName(this.getDeclaringClass().getSimpleName().concat(".consumerName.").concat(this.getCode().toString()));
    }

    public String getSupplierName() {
        return LanguageHolder.getName(this.getDeclaringClass().getSimpleName().concat(".supplierName.").concat(this.getCode().toString()));
    }

    public static String getMessage(Integer code, Boolean isSupplier) {
        if (isSupplier) {
            return Arrays.stream(ReplaceDeliveryGoodsStatusEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(ALL).getSupplierName();
        } else {
            return Arrays.stream(ReplaceDeliveryGoodsStatusEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(ALL).getConsumerName();
        }
    }
}
